import Vue from 'vue';
import App from './App';
import router from './router';
import axios from 'axios';//ajax
// import qs from 'qs';//
import "babel-polyfill";
import { LoadingPlugin, AlertPlugin, ToastPlugin } from 'vux';

Vue.use(ToastPlugin, {position: 'bottom', type: 'text', width: '60%'});
Vue.use(LoadingPlugin);
Vue.use(AlertPlugin);

Vue.prototype.$axios = axios;

router.beforeEach(({meta, path}, from, next) => {
    var { auth = true } = meta
    // var isLogin = Boolean(store.state.user.id) //true用户已登录， false用户未登录
    var isLogin = Boolean(localStorage.getItem('guid'));

    if (auth && !isLogin && path !== '/login' && path !== '/forgetpwd' && path !== '/' && path !== '/way') {
        return next({ path: '/' })
    }
    next()
})

new Vue({
    router,
    render: h => h(App)
}).$mount('#app');
